home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / security / Watcher / Docs / Paper < prev    next >
Encoding:
Text File  |  1987-05-19  |  13.5 KB  |  286 lines

  1. .TI Keeping watch over the flocks
  2. .TI by night (and day)
  3. .AU 7
  4. Kenneth Ingham
  5. University of New Mexico Computing Center
  6. Distributed Systems Group
  7. 2701 Campus NE
  8. Albuquerque, NM 87131
  9. (505) 277-8044
  10. ingham@charon.unm.edu  or ucbvax!unmvax!charon!ingham
  11. .AB
  12. Over the last several years, the number of machines maintained by the
  13. University of New Mexico Computing Center has increased rapidly, yet
  14. the number of system managers monitoring these systems has remained
  15. static.  Consequently, the system managers were faced with the task of
  16. watching more and more machines; since only one system manager is on
  17. call at any time (known affectionately as "DOC"), this soon proved to
  18. be an unacceptable situation.  Shell scripts running every six hours
  19. gave some assistance; this was offset by the fact that the scripts
  20. generated a great deal of output indicating normal system operation,
  21. which the system manager still had to scan carefully for signs of
  22. trouble.  This paper describes \fIwatcher\fR, a flexible system monitor
  23. which watches the system more closely than the human system manager
  24. while generating less output for him to examine.
  25. .sp
  26. Running more often than the above mentioned set of shell scripts,
  27. \fIwatcher\fR is able to keep closer tabs on the system; since it
  28. delivers only a list of potential problems, however, this extra
  29. monitoring produces \fIno\fR corresponding increase in the demand on
  30. DOC.  No problems slip by unnoticed in the more concise output,
  31. leading to an improvement in overall system availability as well as the
  32. more effective utilization of the system manager's time.
  33. .BD
  34. .SE 0. Acknowledgments (I couldn't have done it without you)
  35. I would like to thank Leslie Gorsline for her assistance in the writing
  36. of this paper.  Without her, this paper might not have been.  Also
  37. thanks to the UNMCC distributed systems group for their comments that helped
  38. improve \fIwatcher\fR.
  39. .SE 1. Background (the problem)
  40. The computing facilities offered by the University of New Mexico
  41. Computing Center (UNMCC) include three microvaxen, five large vaxen
  42. (780 or bigger), and a Sequent B8000.  In addition to these Unix/VMS
  43. machines, the UNMCC Distributed Systems Group (DSG) monitors a number
  44. of the various microvaxen and sun workstations scattered across
  45. campus.  This duty falls to the DSG Programmer designated as "DOC", or
  46. "DSG On Call", who receives his beeper based on a monthly rotation
  47. schedule.
  48. .sp
  49. In the past, shell scripts running every six hours reported various
  50. system statistics to DOC, who then scanned the output for signs of
  51. possible trouble.  The output of these shell scripts became
  52. overwhelming as the number of machines and potential problems grew;
  53. corresponding to this increase in output was an increase in the amount
  54. of time that DOC had to spend reading this output.  In addition, most
  55. of this output merely indicated normal system operation; potential
  56. problems were buried amongst non-problems.  Because of this, DOC could
  57. often waste a tremendous amount of time wading through system status
  58. reports, time which can be better spent actually fixing system
  59. problems.
  60. .sp
  61. Unix is equipped with many powerful tools for program development, but
  62. none which simply watch the system for signs of trouble.  Programs like
  63. \fIps\fR and \fIdf\fR provide information regarding the current state
  64. of the machine, yet it still remains DOC's responsibility to interpret
  65. this information and assess the health of the system at any given
  66. time.  This deficiency can be rectified by providing the
  67. system with the capacity to determine its own state of health, advising
  68. DOC when it notices a problem which requires DOC's intervention.
  69. .SE 2. Design Goals (devising the solution)
  70. In designing \fIwatcher\fR, the author closely examined just what DOC
  71. does in monitoring the system; just how \fIdoes\fR DOC spot potential
  72. trouble in the DOC reports?  These reports consist of output from \fIdf
  73. -i\fR, \fIruptime\fR, \fIps -aux | sort\fR, and the tail of
  74. \fIcronlog\fR, which usually only changes in the middle of the night.
  75. It was determined that DOC's task consisted primarily of scanning
  76. various numbers in this output, deciding whether or not they had
  77. exceeded an allowable maximum or minimum, or if the values had changed
  78. too much from the last time the command was run, assuming the last
  79. value is even remembered.  Getting a computer to do this is more
  80. complicated than might seem at first glance, due to inconsistencies in
  81. the location of pertinent information between runs of these commands.
  82. For instance, the process occupying the fifth line of \fIps -ax\fR
  83. might next time appear on the eighth line; similarly, \fIuptime\fR does
  84. not consistently put germane information in the same place on the line.
  85. .sp
  86. While flexibility is certainly a primary design consideration, it is
  87. not the whole story.  In order to improve DOC's effectiveness, the
  88. program should run frequently, roughly every two or three hours,
  89. catching problems early (hopefully before they have affected
  90. the users).  Thus, the program should also be as silent as possible
  91. except when it detects a potential problem; any advantage DOC gains in
  92. using \fIwatcher\fR would be eliminated if the program delivered an
  93. exceedingly verbose status report every two hours.  \fIwatcher\fR's
  94. problem reports should be exact and concise, leading DOC immediately to
  95. the trouble.
  96. .sp
  97. The problem of reducing the amount of output DOC must process can be
  98. approached in different ways, including the redesign of the current
  99. shell scripts.  A simple \fIawk\fR script can watch the output from
  100. \fIdf\fR [1].  However, each command would require a custom tailored
  101. \fIawk\fR script to look at it.  This task grows more complicated as the
  102. number of programs running increases.
  103. While a program could be written to
  104. generate these \fIawk\fR scripts, this process is needlessly complex;
  105. for only a bit more work, an efficient C program such as
  106. \fIwatcher\fR can be developed.  
  107. .SE 3. Design (actual implementation of the solution)
  108. Run at intervals specified in \fIcrontab\fR, \fIwatcher\fR parses a
  109. control file (./\fIwatcherfile\fR by default)
  110. with a \fIyacc\fR generated parser, building a data structure
  111. containing all of the information from the file.  The file contains the
  112. list of commands \fIwatcher\fR
  113. should run (the pipeline), output specifications
  114. for each command (the output format), and the guidelines used in
  115. determining if something is amiss and should be reported to DOC (the
  116. change format).  A sample \fIwatcher\fR control file would look
  117. something like this (comment lines begin with a '#'):
  118. .EX
  119. # Here is the pipeline and its alias:
  120. (df -i | /usr/ucb/tail +2) { df }
  121. # the output format; this is a column output format:
  122.     $1-9 device%k $41-42 spaceused%d $64-65 inodesused%d:
  123. # and the change format:
  124.         spaceused 15%;
  125.         spaceused 0 89;
  126.         inodesused 15%;
  127.         inodesused 0 49.
  128.  
  129. # another command example:
  130. (/usr/ucb/ruptime | fgrep -f UnmHosts) { ruptime }
  131. # this is a relative output format
  132.     2 status%s 1 machine%k 7 loadav%d:
  133. # and another change format:
  134.         loadav 0 10;
  135.         status "up".
  136. .NX
  137. The first entry causes \fIwatcher\fR to run the \fIdf\fR pipeline
  138. listed in parentheses.  When reporting problems, \fIwatcher\fR refers
  139. to this command by the alias provided in the braces; if no alias
  140. appears, \fIwatcher\fR uses the entire pipeline.  
  141. .sp
  142. The output format
  143. instructs \fIwatcher\fR how to parse the output;
  144. column format, indicated in the output format by \fBnum-num\fR,
  145. instructs \fIwatcher\fR that the output should be parsed
  146. by columns, while relative format, denoted by a single integer, shows
  147. that the output should be broken up by whitespaces.
  148. Through the convention \fBname%type\fR, the output format also names each
  149. field, indicating whether the field is numeric, string, or
  150. keyword, specified by \fBd\fR, \fBs\fR, or \fBk\fR respectively.
  151. Keyword fields are
  152. used to match up corresponding output lines between runs.  Thus
  153. .EX
  154.     41-42 spaceused%d
  155. .NX
  156. indicates that this field, named \fBspaceused\fR, contains numeric 
  157. information in columns 41-42, while
  158. .EX
  159.     2 status%s
  160. .NX
  161. informs \fIwatcher\fR that the second word (group of non-whitespace
  162. characters) on the line is a string field named \fBstatus\fR.
  163. For the \fIdf\fR example given above,
  164. .EX
  165. Filesystem    kbytes    used   avail  capacity   iused   ifree  %iused  Mounted on
  166. /dev/hp1f      52431   39763    7424    84%    6937    9447    42%   /develop
  167. .NX
  168. \fBdevice\fR would be \fI/dev/hp1f\fR, \fBspaceused\fR would be 84,
  169. and \fBinodesused\fR would be 42.  Similarly, the output from the
  170. \fIruptime\fR example, which looks like this
  171. .EX
  172. charon        up 26+07:53,    17 users,  load 3.12, 2.90, 2.66
  173. .NX
  174. would be broken at the following places:
  175. .EX
  176. charon | up | 26+07:53, | 17 | users, | load | 3.12, | 2.90, | 2.66,
  177. .NX
  178. assigning "up" to \fBstatus\fR, and 3.12 to \fBloadav\fR.
  179. .sp
  180. The name field also appears in the change format, designating allowable
  181. values for this field to have.  These values can be specified as 
  182. single character strings in the case of string fields; in the case of
  183. numeric fields, the values take the form of either
  184. percentage or absolute changes, or a minimum and maximum which delineate
  185. an acceptable range.
  186. Thus
  187. .EX
  188.     inodesused 15%;
  189.     inodesused 0 49.
  190. .NX
  191. signifies that DOC should be notified if the field named \fBinodesused\fR
  192. increases by more than 15% from the last run, or if it is outside the
  193. range 0 to 49; similarly
  194. .EX
  195.     status "up";
  196. .NX
  197. informs \fIwatcher\fR to notify DOC if the \fBstatus\fR field contains
  198. anything other than the word "up".
  199. .sp
  200. As \fIwatcher\fR parses the output of a pipeline, it stores the
  201. pertinent parts of the output in a history file (by
  202. default, ./\fIwatcher.history\fR).
  203. The next time \fIwatcher\fR runs, it reads this file to provide
  204. comparison values for the command.  If a command is new (i.e. it has no
  205. previously-stored output in the history file), \fIwatcher\fR checks the
  206. fields which require no previous data, such as min-max fields, while
  207. still storing \fIall\fR of the relevant information to the history file.
  208. Thus, the next time the new command is run, it will be an \fIold\fR command,
  209. and meaningful between-run comparisons can be made.
  210. .sp
  211. When \fIwatcher\fR
  212. detects no problems with the system, DOC receives an empty mail message
  213. with the subject "\fIhostname\fR had no problems at \fIdate\fR";
  214. this is to insure that \fImail\fR is running correctly.  
  215. When it notices a problem which should be brought to DOC's attention,
  216. it mails the system problem report in a concise
  217. format, explaining what is wrong and why.  
  218. Thus, rather than the megabytes of shell script output that DOC
  219. used to receive and have to read,
  220. he merely sees this when he reads his mail:
  221. .EX
  222. Mail version 5.2 6/21/85.  Type ? for help.
  223. "/usr/spool/mail/ingham": 5 messages 5 new
  224.  N  1 root@charon.unm Sat Apr 11 16:00  8/212  "charon had no problems at Sat"
  225.  N  2 root@ariel.unm Sat Apr 11 16:00  8/208  "ariel had no problems at Sat "
  226.  N  3 root@geinah.unm Sat Apr 11 16:00  11/417 "System problem report for gei"
  227.  N  4 root@izar.unm Sat Apr 11 16:00  8/204  "izar had no problems at Sat A"
  228.  N  5 root@deimos.unm Sat Apr 11 16:00  8/212  "deimos had no problems at Sat"
  229. .NX
  230. The letters indicating no problems can be immediately deleted, and DOC
  231. can turn his attention to the letter indicating a 
  232. system problems.  A sample problem report
  233. would look something like this:
  234. .EX
  235. df has a max/min value out of range:
  236. /dev/hp0h     140488  111195   15244    91%   10145   28767    26%   /usr
  237. where spaceused = 91.00; valid range 0.00 to 89.00.
  238. Also it had inodesused change by more than 10%.
  239. Previous value 20.00; current value 26.00.
  240. .NX
  241. Note that if a line has more than one indication of a problem, all
  242. anomalies are included in the report.
  243. This provides DOC with as much information as possible, allowing him
  244. to determine the problem quickly and devise 
  245. a rapid fix (hopefully before users know something is amiss).  
  246. .sp
  247. .SE 4. Results (how its helped us)
  248. \fIwatcher\fR's primary advantage lies in the reduction of DOC's work
  249. load.  It has taken over the more menial aspects of monitoring a system,
  250. tasks like reading and comparing numbers, 
  251. giving DOC more time to concentrate on bugs of a nature which
  252. \fIwatcher\fR isn't set up to monitor, such as problems in the
  253. accounting system.
  254. DOC is apprised of potential problems quickly, and in
  255. some cases can repair them in less time than simply
  256. reading the shell script output
  257. would have taken.
  258. .sp
  259. The ability to monitor changes between runs has also helped bring to our
  260. attention some
  261. problems which were missed in the DOC reports.  For example,
  262. disk space on \fI/u2\fR on one of our machines jumped by more than 15%.  Since
  263. this jump did not force the total space used above 90%, at which point
  264. DOC would have investigated the filesystem, it is unlikely
  265. that DOC would have even noticed this sudden change.  The facility to
  266. watch for relative changes between runs enables DOC to catch problems in
  267. their infancy, and fix problems such as filesystems filling up too
  268. rapidly before they inconvenience the users.
  269. .sp
  270. Since the system manager specifies not only the commands \fIwatcher\fR will
  271. execute and the time lapse between successive runs, but also the
  272. parameters which indicate system anomalies,
  273. \fIwatcher\fR can easily be seen as a very flexible, general system
  274. monitor.  Its use at UNM has provided an increase in the
  275. productivity of the system manager, which has led in turn to the
  276. increase in the reliability and availability of the systems at UNMCC.
  277. .SE 5. Availability (how to get one)
  278. \fIwatcher\fR will be sent to the moderator of mod.sources after the
  279. conference is over.
  280. .SE 6. References (you might also find this interesting)
  281. .in +0.5i
  282. .ti -0.5i
  283. [1] Monitoring Free Disk Space, Rik Farrow, Wizard's Grabbag, \fIUnix
  284. World\fR, Vol. IV, no. 3, pp. 86-87.
  285. .in -0.5i
  286.